package com.atguigu.springanalysis;

import com.atguigu.springanalysis.config.ConfigBean;
import com.atguigu.springanalysis.model.Person;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.beans.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Main {
    public static void main(String[] args) throws IntrospectionException {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ConfigBean.class);
        String message = applicationContext.getMessage("message", null, "ABC", null);
        System.out.println(message);
        String message02 = applicationContext.getMessage("argument.required", new Object[]{"userDao"}, "Required", Locale.UK);
//        String message02 = applicationContext.getMessage("argument.required", new Object[]{"userDao"}, "Required", null);
        System.out.println(message02);
        ArrayList a  = new ArrayList();
        Map map = new HashMap();
        Map map1 = new ConcurrentHashMap();

        BeanInfo bif = Introspector.getBeanInfo(Person.class);
        PropertyDescriptor[] pd = bif.getPropertyDescriptors();
        for(int i=0;i<pd.length;i++){
            System.out.println("name:"+pd[i].getName());
            System.out.println("read method name:"+pd[i].
                    getReadMethod ().getName());
            System.out.println("displayname:"+pd[i].getDisplayName());
        }
        MethodDescriptor[] md = bif.getMethodDescriptors();for(int m = 0; m<md.length; m++){
            System.out.println("name:"+md[m].getName());
            System.out.println("method name:"+md[m].getMethod().getName());
            System.out.println("displayname:"+md[m].getDisplayName());
        }
        BeanDescriptor bd = bif.getBeanDescriptor();
        System.out.println("display name：" + bd.getDisplayName());
        System.out.println("name：" + bd.getName());
        EventSetDescriptor[] esd = bif.getEventSetDescriptors();
        for(int m=0;m<esd.length;m++){
            System.out.println("name:"+esd[m].getName());
            System.out.println("method name:"+esd[m].getGetListenerMethod().getName());
            System.out.println("method name:"+esd[m].getRemoveListenerMethod().getName());
            System.out.println("method name:"+esd[m].getAddListenerMethod().getName());
            System.out.println("displayname:"+esd[m].getDisplayName());
        }

        ThreadPoolExecutor executor = new ThreadPoolExecutor(2,5,10, TimeUnit.SECONDS, new ArrayBlockingQueue(100),new ThreadPoolExecutor.CallerRunsPolicy());
        Object object = new Object();

        CountDownLatch countDownLatch = new CountDownLatch(10);
        countDownLatch.countDown();
        Lock lock = new ReentrantLock();

        LinkedBlockingQueue queue = new LinkedBlockingQueue(10);
//        LinkedBlockingDeque deque = new LinkedBlockingDeque(10);


    }
}
